from transitions import Machine

class Matter(object):
    pass

model = Matter()
#The states argument defines the name of states
states=['solid', 'liquid', 'gas', 'plasma']

# The trigger argument defines the name of the new triggering method
transitions = [
    {'trigger': 'melt', 'source': 'solid', 'dest': 'liquid' },
    {'trigger': 'evaporate', 'source': 'liquid', 'dest': 'gas'},
    {'trigger': 'sublimate', 'source': 'solid', 'dest': 'gas'},
    {'trigger': 'ionize', 'source': 'gas', 'dest': 'plasma'}]

machine = Machine(model=model, states=states, transitions=transitions, initial='solid')

# Test
print(model.state)    # solid

model.melt()

print(model.state)   # liquid

model.evaporate()
print(model.state)

# model.sublimate
# print(model.state)



# draw the whole graph ...


# in cases where auto transitions should be visible
# Machine(model=m, show_auto_transitions=True, ...)

# draw the whole graph ...
#model.get_graph(show_roi=True).draw('my_state_diagram.png', prog='dot')

